<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<?php
	if(isset($this->message)){
		$this->display('message');
	}
?>
<script src="templates/cafe/jquery.validate.js" type="text/javascript"></script>
<script language="javascript">
function setUsername(username){
	$("#username").val(username);
}
jQuery(document).ready(function(jQuery) {
   	jQuery("#registerForm").validate(
		{				 
			errorPlacement: function(error, element) {			
		},
		invalidHandler: function(form, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				jQuery('#alert').html(validator['errorList'][0]['message']);
				jQuery('#backoverlay').show();
				jQuery('#show_popup').show();
				jQuery('#f_focus').html(validator['errorList'][0]['element'].id);
				validator['errorList'][0]['element'].focus();
		  	}
		},
		rules: {
			email: {
				required: true,
				email: true
			},
			password: "required",
			password2: {
				required: true, 
				equalTo: "#password"
			},
			company : "required",
			name : "required",
			address : "required",
			post : "required",
			city : "required",
			cvr : "required",
			phone : "required"
		},
		messages: {
			email: "Indtast venligst korrekt e-mail",
			password: "Indtast venligst kodeord",
			password2: "Indtast venligst korrekte adgangskode igen",
			company: "Indtast venligst virksomhed / institution",
			name: "Indtast venligst kontaktperson",
			address: "Indtast venligst adresse",
			post: "Indtast venligst Postnr",
			city: "Indtast venligst by",
			cvr: "Indtast venligst CVR-nr",
			phone: "Indtast venligst telefon"
		}
		
	});
	close_popup=function(){		
		var fel=jQuery('#f_focus').html();
		jQuery('#backoverlay').hide();
		jQuery('#show_popup').hide();
		jQuery('#' + fel ).focus();			
	};
});
</script>
<form action="<?php echo JRoute::_( 'index.php?option=com_user' ); ?>" method="post" id="registerForm" name="registerForm" class="form-validate">
	<div class="form-register">
        <div class="heading">
            <h2>Ny bruger</h2>
        </div>
        <div class="input-block">
            <label for="email">E-mail <span class="red">*</span></label>
            <input type="text" name="email" id="email" onblur="setUsername(this.value)" />
        </div>
        <div class="input-block">
            <label for="password">Password</label>
            <input type="password" name="password" id="password" />
        </div>
        <div class="input-block" id="input-last">
            <label for="password">Gentag password</label>
            <input type="password" name="password2" id="password2" />
        </div>
        <div class="heading">
            <h2>Firma/Institution</h2>
        </div>
        <div class="input-block">
            <label for="Name">Firma/Institution <span class="red">*</span></label>
            <input type="text" name="company" id="company" />
        </div>
        <div class="input-block">
            <label for="email">Kontaktperson <span class="red">*</span></label>
            <input type="text" name="name" id="name" />
        </div>
        <div class="input-block">
            <label for="email">Adresse <span class="red">*</span></label>
            <input type="text" name="address" id="address" />
        </div>
        <div class="input-block clear-fix">
            <div class="input-block-left">
                <label for="Postnr ">Postnr <span class="red">*</span></label>
                <input type="text" name="post" id="post" maxlength="4" />
            </div>
            <div class="input-block-right">
                <label for="by">By <span class="red">*</span></label>
                <input type="text" name="city" id="city" />
            </div>						
        </div>
        <div class="input-block">
            <label for="email">CVR-nr <span class="red">*</span></label>
            <input type="text" name="cvr" id="cvr" />
        </div>
        <div class="input-block">
            <label for="email">Telefon/mobil <span class="red">*</span></label>
            <input type="text" name="phone" id="phone" />
        </div>
        <div class="input-submit clear-fix">
            <a id="btn-register" href="javascript:void(0);" onclick="jQuery('#registerForm').submit();">Register</a>
            <input type="reset" id="btnReset" />
        </div>
    </div>
    <input type="hidden" name="username" id="username" value="" />
	<input type="hidden" name="task" value="register_save" />
	<input type="hidden" name="id" value="0" />
	<input type="hidden" name="gid" value="0" />
	<?php echo JHTML::_( 'form.token' ); ?>
	
</form>
